package com.example.websocket_demo.dao.user_group;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface UserGroupDao {
    @Select("<script> select * from user_group where 1=1 <if test='id!=null'>and id=#{id} </if> <if test='user_id!=null'>and user_id=#{user_id} </if> <if test='group_name!=null'>and group_name=#{group_name} </if> </script>")
    public List<Map<String,Object>> selectUserGroup(Map<String,Object> map);
    @Insert("<script> insert into user_group <trim prefix='(' suffix=')' suffixOverrides=','> <if test='user_id != null and user_id != \"\"'>user_id,</if> <if test='group_name != null and group_name != \"\"'>group_name,</if> </trim> <trim prefix='values (' suffix=')' suffixOverrides=','> <if test='user_id != null and user_id != \"\"'>#{user_id},</if> <if test='group_name != null and group_name != \"\"'>#{group_name},</if> </trim> </script>")
    public int insertUserGroup(Map<String, Object> userMap);
}
